package com.tudouji.project.pay.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tudouji.framework.aspectj.lang.annotation.Log;
import com.tudouji.framework.aspectj.lang.enums.BusinessType;
import com.tudouji.project.pay.domain.PayinfoRecord;
import com.tudouji.project.pay.service.IPayinfoRecordService;
import com.tudouji.framework.web.controller.BaseController;
import com.tudouji.framework.web.domain.AjaxResult;
import com.tudouji.common.utils.poi.ExcelUtil;
import com.tudouji.framework.web.page.TableDataInfo;

/**
 * 支付记录Controller
 *
 * @author tudouji
 * @date 2022-11-10
 */
@RestController
@RequestMapping("/pay/record")
public class PayinfoRecordController extends BaseController
{
    @Autowired
    private IPayinfoRecordService payinfoRecordService;

    /**
     * 查询支付记录列表
     */
//    @PreAuthorize("@ss.hasPermi('pay:record:list')")
    @GetMapping("/list")
    public TableDataInfo list(PayinfoRecord payinfoRecord)
    {
        startPage();
        List<PayinfoRecord> list = payinfoRecordService.selectPayinfoRecordList(payinfoRecord);
        return getDataTable(list);
    }

    /**
     * 导出支付记录列表
     */
    @PreAuthorize("@ss.hasPermi('pay:record:export')")
    @Log(title = "支付记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(PayinfoRecord payinfoRecord)
    {
        List<PayinfoRecord> list = payinfoRecordService.selectPayinfoRecordList(payinfoRecord);
        ExcelUtil<PayinfoRecord> util = new ExcelUtil<PayinfoRecord>(PayinfoRecord.class);
        return util.exportExcel(list, "record");
    }

    /**
     * 获取支付记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('pay:record:query')")
    @GetMapping(value = "/{guid}")
    public AjaxResult getInfo(@PathVariable("guid") String guid)
    {
        return AjaxResult.success(payinfoRecordService.selectPayinfoRecordById(guid));
    }

    /**
     * 新增支付记录
     */
    @PreAuthorize("@ss.hasPermi('pay:record:add')")
    @Log(title = "支付记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PayinfoRecord payinfoRecord)
    {
        return toAjax(payinfoRecordService.insertPayinfoRecord(payinfoRecord));
    }

    /**
     * 修改支付记录
     */
    @PreAuthorize("@ss.hasPermi('pay:record:edit')")
    @Log(title = "支付记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PayinfoRecord payinfoRecord)
    {
        return toAjax(payinfoRecordService.updatePayinfoRecord(payinfoRecord));
    }

    /**
     * 删除支付记录
     */
    @PreAuthorize("@ss.hasPermi('pay:record:remove')")
    @Log(title = "支付记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{guids}")
    public AjaxResult remove(@PathVariable String[] guids)
    {
        return toAjax(payinfoRecordService.deletePayinfoRecordByIds(guids));
    }
}
